home *** CD-ROM | disk | FTP | other *** search
/ Acorn RISC PD-CD 1 / Acorn RISC PD-CD 1.iso / languages / grs / pd_release / g / p2 < prev    next >
Encoding:
Text File  |  1991-04-14  |  2.1 KB  |  55 lines

  1. instanceof class student;
  2.  
  3. assume string house; integer year; instanceof course univ_course in
  4.    student := class.new(
  5.                  "student",
  6.                  [
  7.                     {
  8.                        null function set( string pname; integer page;
  9.                                           string cname; integer clength;
  10.                                           string shouse; integer syear )
  11.                        {
  12.                           assume null function pset(string s;integer p) in
  13.                           {
  14.                            write("\n\npname :",pname,", page :",page,"\n\n");
  15.                            pset(pname,page);
  16.                           };
  17.                           univ_course.set(cname,clength);
  18.                           house := shouse; year := syear;
  19.                        };
  20.                     },
  21.                     {
  22.                        null function show()
  23.                        {
  24.                           write("\n\nStudent details:\n");
  25.                           (*assume null function pshow() in
  26.                              pshow();*)
  27.                           (* need to be able to say super.show *)
  28.                           assume instanceof person super in
  29.                              super.show();
  30.                           univ_course.show();
  31.                           write("\nStudent lives in ",house);
  32.                           write(" and is in year ",year,"\n");
  33.                           write("There are ",univ_course.get_length()-year+1,
  34.                                 " years left\n\n");
  35.                        };
  36.                     },
  37.                     {
  38.                        null function s()
  39.                        {
  40.                           sys_describe_object();
  41.                        };
  42.                     }
  43.                  ],
  44.                  [
  45.                     {
  46.                        string house;
  47.                        integer year;
  48.                        create course univ_course;
  49.                     }
  50.                  ]
  51.                  );
  52.  
  53. person.replace_method("show",{ integer function show() { return 1; }; } );
  54. person.delete_method("show",true);
  55.